using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using RestNews.Data.Models.Mapping;

namespace RestNews.Data.Models
{
    public class RestNewsContext : DbContext
    {
        static RestNewsContext()
        {
            Database.SetInitializer<RestNewsContext>(null);
        }

		public RestNewsContext()
			: base("Name=RestNewsContext")
		{
		}

        public DbSet<Category> Categories { get; set; }
        public DbSet<NewsItem> NewsItems { get; set; }
        public DbSet<NewsItemCategory> NewsItemCategories { get; set; }
        public DbSet<NonceStorage> NonceStorages { get; set; }
        public DbSet<Person> People { get; set; }
        public DbSet<PersonReadNew> PersonReadNews { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<User> Users { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new CategoryMap());
            modelBuilder.Configurations.Add(new NewsItemMap());
            modelBuilder.Configurations.Add(new NewsItemCategoryMap());
            modelBuilder.Configurations.Add(new NonceStorageMap());
            modelBuilder.Configurations.Add(new PersonMap());
            modelBuilder.Configurations.Add(new PersonReadNewMap());
            modelBuilder.Configurations.Add(new RoleMap());
            modelBuilder.Configurations.Add(new UserMap());
        }
    }
}
